
// wglcamera.hpp
//

#ifndef _WGLCAMERA_HPP
#define _WGLCAMERA_HPP

#include "wgl/wglbase.hpp"

#include "glm/mat4x4.hpp"

namespace wgl
{
  // CameraType
  //
  enum class CameraType
    {
      Orthographic,
      Perspective,
    };


  
  // Camera
  //
  class Camera
  {
  public:
    Camera ( CameraType type=CameraType::Perspective );
    
    const glm::mat4 &get_matrix ();
    const glm::vec3 &get_position () const { return position; }
    const glm::vec3 &get_rotation () const { return rotation; }
    
    void set_fov ( float fov );
    void set_aspect_ratio ( float aspect_ratio );
    void set_z_clip ( float z_near,
                      float z_far );

    void set_position ( glm::vec3 position );
    void set_rotation ( glm::vec3 rotation );
    
  private:
    bool proj_dirty{true};
    bool view_dirty{true};
    
    CameraType type{CameraType::Perspective};
    
    glm::mat4 m_vp{1.f};
    glm::mat4 m_proj{1.f};
    glm::mat4 m_view{1.f};

    float fov{.7854f}; // 45deg
    float aspect_ratio{1.f};
    float z_near{.1f};
    float z_far{1000.f};

    glm::vec3 position{};
    glm::vec3 rotation{};
  };
}

#endif
